<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>VirtualScroll</title>
    <style>
        .container,
        .container2 {
            position: relative;
            height: 200px;
            overflow: scroll;
            border: thin solid #ccc;
        }
        .item {
            height: 40px;
            padding: 0 20px;
            line-height: 40px;
            border-bottom: thin solid #eee;
            box-sizing: border-box;
        }
        .border {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 200px;
            outline: 2px solid #12464c;
            background-color: #00bcd47a;
            z-index: 1;
        }
        .vs__scroll {
            position: absolute;
            top: 0;
            right: 0;
            width: 20px;
            height: 100%;
            background-color: #333;
            z-index: 2;
        }
        .vs__scrollbar {
            width: 100%;
            min-height: 20px;
            background-color: azure;
            cursor: pointer;
        }
    </style>
</head>
<body>
<h1>虚拟滚动</h1>
<p>数据条数：100,000</p>
<p>渲染耗时：<span class="js-perf-v"></span></p>
<div class="container">
    <div class="border"></div>
</div>
<!-- <div class="container2"></div> -->
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<h1>虚拟滚动</h1><h1>虚拟滚动</h1><h1>虚拟滚动</h1>
<script type="module">
  import VirtualScroll from "./VirtualScroll.js"
  var $el = document.querySelector(".container")
  var $el2 = document.querySelector(".container2")
  var $list = document.querySelector(".list-wp")
  var $perfV = document.querySelector(".js-perf-v")
  var $perfNC = document.querySelector(".js-perf-nc")

  var list = []
  for (let i = 0; i < 100; i++) {
    list.push(i)
  }

  let tV = Date.now()
  window.vs = new VirtualScroll(
    $el,
    list,
    (item) => {
      const $item = document.createElement("div")
      $item.classList.add("item")
      $item.innerHTML = item.raw

      return $item
    },
    {
      cacheCount: 4,
    }
  )
  $perfV.innerHTML = Date.now() - tV + "ms"


</script>
</body>
</html>
